//
//  HistoryViewCell.m
//  EPBPro
//
//  Created by wucha on 2018/6/27.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "HistoryViewCell.h"
@interface HistoryViewCell()
@property (nonatomic,strong) UILabel *timeLabel;
@property (nonatomic,strong) UILabel *titleLabel;

@end

@implementation HistoryViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
        UILabel *timeLabel = [UILabel new];
        timeLabel.numberOfLines = 0;
        timeLabel.text = @"2018-12-12";
        [self.contentView addSubview:timeLabel];
        timeLabel.sd_layout.topSpaceToView(self.contentView, 0).leftSpaceToView(self.contentView, 20).widthIs(100).bottomSpaceToView(self.contentView, 0);
        self.timeLabel = timeLabel;
        
        UIView *lineView = [UIView new];
        lineView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:lineView];
        lineView.sd_layout.leftSpaceToView(timeLabel, 10).topSpaceToView(self.contentView, 0).bottomSpaceToView(self.contentView, 0).widthIs(1);
        
        UIView *pointView = [UIView new];
        pointView.layer.cornerRadius =2.5;
        pointView.backgroundColor = [UIColor grayColor];
        [self.contentView addSubview:pointView];
        pointView.sd_layout.leftSpaceToView(timeLabel, 8).centerYEqualToView(self.contentView).widthIs(5).heightIs(5);
        
        UILabel *titleLabel = [UILabel new];
        titleLabel.numberOfLines = 0;
        titleLabel.text = @"";
        [self.contentView addSubview:titleLabel];
        titleLabel.sd_layout.topSpaceToView(self.contentView, 20).leftSpaceToView(lineView, 20).widthIs(SCREEN_WIDTH-100).autoHeightRatio(0);
        self.titleLabel = titleLabel;
        
        [self setupAutoHeightWithBottomView:titleLabel bottomMargin:20];

    }
    
    return self;
}

-(void)setHistroyCell:(MaintainInfo*)maintainInfo{
    self.timeLabel.text = [Utils getTimeFront:maintainInfo.startDate];
    if (maintainInfo.maintainComment&&![maintainInfo.maintainComment isEqualToString:@""]) {
        self.titleLabel.text = [NSString stringWithFormat:@"%@\n--%@",maintainInfo.descriptions,maintainInfo.maintainComment];

    }else{
        self.titleLabel.text = maintainInfo.descriptions;

    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
